package com.study.util;

import org.apache.commons.beanutils.BeanUtils;

import javax.servlet.http.HttpServletRequest;

public class MyBeanUtils {

    public static <T> T copyToBean(HttpServletRequest request, Class<T> clazz) {
        try {
            // （注册日期类型转换器）
            // 创建对象
            T t = clazz.newInstance();
            BeanUtils.populate(t, request.getParameterMap());
            return t;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
 }   
 